//
//  XiTongRenWuViewController.m
//  firstpoint
//
//  Created by 泽中 on 2017/6/30.
//  Copyright © 2017年 xzcysoft. All rights reserved.
//

#import "XiTongRenWuViewController.h"
#import "RenWuTableViewCell.h"
#import "RenWuXiangQingViewController.h"
@interface XiTongRenWuViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    UITableView*tabView;
    int page;
}

@property(nonatomic,strong)NSMutableArray *bigMutArr;
@end

@implementation XiTongRenWuViewController
-(void)viewWillAppear:(BOOL)animated{
    page=1;
    _bigMutArr = [NSMutableArray array];
     [self httpRquestUrl];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"系统任务";
     self.view.backgroundColor=[UIColor whiteColor];
    [self setTab];
    
    
}

-(void)setTab
{
    tabView=[[UITableView alloc]initWithFrame:CGRectMake(0, 64, width_screen, height_screen-64) style:1];
    tabView.separatorStyle=0;
    tabView.delegate=self;
    //    tabView.mj_header
    tabView.dataSource=self;
    [tabView registerClass:[RenWuTableViewCell class] forCellReuseIdentifier:@"cell"];
    [self.view addSubview:tabView];
    
    
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 100;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return _bigMutArr.count;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 40;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    RenWuTableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"cell"];
    
    if (_bigMutArr.count>1) {
        cell.titleLab.text = [NSString stringWithFormat:@"%@",_bigMutArr[indexPath.row][@"title"]];//b标题
        cell.infoLab.text = [NSString stringWithFormat:@"%@",_bigMutArr[indexPath.row][@"description"]];//内容
        
        
        if ([_bigMutArr[indexPath.row][@"rewardType"]intValue]==1001){
            cell.jindouLab.text = [NSString stringWithFormat:@"%@ 元宝",_bigMutArr[indexPath.row][@"everyoneAmount"]];//金豆
        }
        if ([_bigMutArr[indexPath.row][@"rewardType"]intValue]==1002){
            cell.jindouLab.text = [NSString stringWithFormat:@"%@ 金币",_bigMutArr[indexPath.row][@"everyoneAmount"]];//金豆
        }
        if ([_bigMutArr[indexPath.row][@"rewardType"]intValue]==1003){
            cell.jindouLab.text = [NSString stringWithFormat:@"%@ 金豆",_bigMutArr[indexPath.row][@"everyoneAmount"]];//金豆
        }
        if ([_bigMutArr[indexPath.row][@"rewardType"]intValue]==1004){
            cell.jindouLab.text = [NSString stringWithFormat:@"%@ 额度",_bigMutArr[indexPath.row][@"everyoneAmount"]];//金豆
        }
        if ([_bigMutArr[indexPath.row][@"rewardType"]intValue]==1005){
            cell.jindouLab.text = [NSString stringWithFormat:@"%@ 成长值",_bigMutArr[indexPath.row][@"everyoneAmount"]];//金豆
        }
        
        
        
        //            cell.jindouLab.text = [NSString stringWithFormat:@"%@ 金豆",_bigMUArr[indexPath.row][@"payTypeId"]];//金豆
        cell.youxiajiaoLab.text = [NSString stringWithFormat:@"参与人数 %@",_bigMutArr[indexPath.row][@"counts"]];//参与
    }
    
    
    
//    if (_bigMutArr.count>1) {
//        cell.titleLab.text = [NSString stringWithFormat:@"%@",_bigMutArr[indexPath.row][@"title"]];//b标题
////        cell.chengzhangLab.text = [NSString stringWithFormat:@"%@",_bigMutArr[indexPath.row][@"description"]];//内容
//        if ([_bigMutArr[indexPath.row][@"rewardType"]intValue]==1001){
//            cell.jindouLab.text = [NSString stringWithFormat:@"%@ 元宝",_bigMutArr[indexPath.row][@"everyoneAmount"]];//金豆
//        }
//        if ([_bigMutArr[indexPath.row][@"rewardType"]intValue]==1002){
//            cell.jindouLab.text = [NSString stringWithFormat:@"%@ 金币",_bigMutArr[indexPath.row][@"everyoneAmount"]];//金豆
//        }
//        if ([_bigMutArr[indexPath.row][@"rewardType"]intValue]==1003){
//            cell.jindouLab.text = [NSString stringWithFormat:@"%@ 金豆",_bigMutArr[indexPath.row][@"everyoneAmount"]];//金豆
//        }
//        if ([_bigMutArr[indexPath.row][@"rewardType"]intValue]==1004){
//            cell.jindouLab.text = [NSString stringWithFormat:@"%@ 额度",_bigMutArr[indexPath.row][@"everyoneAmount"]];//金豆
//        }
//        if ([_bigMutArr[indexPath.row][@"rewardType"]intValue]==1005){
//            cell.jindouLab.text = [NSString stringWithFormat:@"%@ 成长值",_bigMutArr[indexPath.row][@"everyoneAmount"]];//金豆
//        }
//        
//        cell.button.tag = 20+indexPath.row;
    
//        if ([_bigMutArr[indexPath.row][@"taskTypeId"]intValue]==5) {
//            [cell.button setTitle:@"系统分享任务" forState:UIControlStateNormal];
//        }else if ([_bigMutArr[indexPath.row][@"taskTypeId"]intValue]==6){
//            [cell.button setTitle:@"新手上传头像" forState:UIControlStateNormal];
//        }else if ([_bigMutArr[indexPath.row][@"taskTypeId"]intValue]==7){
//            [cell.button setTitle:@"新手完善资料" forState:UIControlStateNormal];
//        }else if ([_bigMutArr[indexPath.row][@"taskTypeId"]intValue]==8){
//            [cell.button setTitle:@"系统任务列表" forState:UIControlStateNormal];
//        }else if ([_bigMutArr[indexPath.row][@"taskTypeId"]intValue]==9){
//            [cell.button setTitle:@"系统邀请好友" forState:UIControlStateNormal];
//        }else if ([_bigMutArr[indexPath.row][@"taskTypeId"]intValue]==10){
//            [cell.button setTitle:@"系统购买商品" forState:UIControlStateNormal];
//        }else if ([_bigMutArr[indexPath.row][@"taskTypeId"]intValue]==11){
//            [cell.button setTitle:@"新手任务列表" forState:UIControlStateNormal];
//        }else if ([_bigMutArr[indexPath.row][@"taskTypeId"]intValue]==12){
//            [cell.button setTitle:@"新手邀请好友" forState:UIControlStateNormal];
//        }
//        [cell.button addTarget:self action:@selector(wangchengBtnClcike:) forControlEvents:UIControlEventTouchUpInside];
        
    
    
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
//    [self.navigationController popToRootViewControllerAnimated:YES];
}
////去完成任务按钮
-(void)wangchengBtnClcike:(UIButton *)button{
     [self.navigationController popToRootViewControllerAnimated:YES];
}

-(void)sousuoRenwuBtnClcike{
    
}

#pragma mark---RquestURL
-(void)httpRquestUrl{
   
    
        //系统任务
         NSString * bigURL = [NSString stringWithFormat:@"%@%@",LINK_BASE_URL(@"task/systemTaskList.api?access_token="),NSUD_Obj(@"token")];
    
    [HTTPURL postRequest:bigURL parameters:@{} success:^(NSURLSessionDataTask *task, id responseObject) {
        NSArray *array = [NSArray array];
        array = (NSArray *)[PublicTools dictionaryWithJsonString:responseObject[@"data"]];
        [_bigMutArr addObjectsFromArray:array];
        [tabView reloadData];
    } filure:^(NSURLSessionDataTask *task, id error) {
        NSLog(@"%@",error);
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
